class ControlStateDto {
  constructor(targetX, targetY, targetZ, objectX, objectY, objectZ) {
    this.targetX = targetX;
    this.targetY = targetY;
    this.targetZ = targetZ;
    this.objectX = objectX;
    this.objectY = objectY;
    this.objectZ = objectZ;
  }
}

export const getControlState = (controls) => {
  controls.update();
  return new ControlStateDto(
    controls.target.x,
    controls.target.y,
    controls.target.z,
    controls.object.position.x,
    controls.object.position.y,
    controls.object.position.z,
  );
};

export const printControlState = (controls) => {
  const controlState = getControlState(controls);
  console.log("%c控制器位置信息已复制到剪贴板", "background: #00bcd4; padding: 2px 4px; border-radius: 2px; color: white;");
  navigator?.clipboard?.writeText(JSON.stringify(controlState, null, 4));
};
